home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / handson / supercede / Knowodys / Projects / AddText / 1.1 / MainComponent / Form1.java < prev    next >
Encoding:
Java Source  |  1997-07-20  |  6.0 KB  |  239 lines

  1. /**
  2.  * 
  3.  * You can add code anywhere in this file - except in the areas that are
  4.  * written by the editor. You should not change the relative ordering of
  5.  * the code.
  6.  * 
  7.  * You can remove this comment block or replace it with another.
  8.  * 
  9.  * @see        
  10.  * @version    
  11.  * @author    
  12.  */
  13.  
  14.  
  15. import com.supercede.forms.*;
  16. import java.util.*;
  17. import java.net.*;
  18. import java.io.*;
  19. import java.beans.*;
  20. import java.awt.event.*;
  21. import java.awt.*;
  22.  
  23. public class Form1 extends SuperCedeFrame implements Serializable
  24. {
  25.  
  26.     public Form1() throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException
  27.     {
  28.         SuperCedeConstructor();        // Do not remove this line.
  29.     }
  30.  
  31.     public static void main(String args[])
  32.     {
  33.         // You can add code anywhere in this method.
  34.  
  35.         try
  36.         {
  37.             Form1 app = new Form1();
  38.             app.setVisible(true);
  39.         }
  40.         catch(Throwable t)
  41.         {
  42.             System.out.println("Cannot construct the form: " + t);
  43.             System.exit(1);
  44.         }
  45.     }
  46.  
  47.     public void form1WindowClosing(WindowEvent e)
  48.     {
  49.         // You can add code anywhere in this method.
  50.  
  51.         dispose();
  52.     }
  53.  
  54.     public void form1WindowClosed(WindowEvent e)
  55.     {
  56.         // You can add code anywhere in this method.
  57.  
  58.         SuperCedeWindowClosed();
  59.     }
  60.  
  61.     public void inputFieldActionPerformed(ActionEvent arg0)
  62.     {
  63.         // Put event handler code here...
  64.         myTextArea.append(inputField.getText()+"\n");
  65.         inputField.selectAll();
  66.         inputField.requestFocus();
  67.     }
  68.  
  69. public void addButtonActionPerformed(ActionEvent arg0)
  70.     {
  71.         // Put event handler code here...
  72.         myTextArea.append(inputField.getText()+"\n");
  73.         inputField.selectAll();
  74.         inputField.requestFocus();
  75.     }
  76.  
  77. public void clearButtonActionPerformed(ActionEvent arg0)
  78.     {
  79.         // Put event handler code here...
  80.         myTextArea.setText("");
  81.         inputField.requestFocus();
  82.     }
  83.  
  84.     // SuperCede Begin 2.0 Form Members
  85.     // Do not remove the Begin and End markers.
  86.     // The editor will rewrite the contents of this section each time the form is saved.
  87.  
  88.     // References to Beans within the Form.
  89.  
  90.     TextField inputField;
  91.     Button addButton;
  92.     Button clearButton;
  93.     com.supercede.beans.stdawt.TextAreaSB myTextArea;
  94.  
  95.     private final void SuperCedeConstructor() throws IOException, ClassNotFoundException, ClassCastException, SuperCedeInvalidStateException
  96.     {
  97.         // Construct the actual connectors to give to our base class.
  98.  
  99.         Vector connectors = new Vector(5);
  100.         connectors.addElement(new Form1WindowClosingConnector0());
  101.         connectors.addElement(new Form1WindowClosedConnector1());
  102.         connectors.addElement(new Form1EventConnector3());
  103.         connectors.addElement(new Form1EventConnector4());
  104.         connectors.addElement(new Form1EventConnector5());
  105.  
  106.         super.initializeThis(connectors);
  107.  
  108.         // Make references to Beans within the Form.
  109.  
  110.         int i = 0;
  111.  
  112.         inputField = (TextField) getComponent(i++);
  113.         addButton = (Button) getComponent(i++);
  114.         clearButton = (Button) getComponent(i++);
  115.         myTextArea = (com.supercede.beans.stdawt.TextAreaSB) getComponent(i++);
  116.     }
  117.  
  118.     private final void SuperCedeWindowClosed()
  119.     {
  120.         System.exit(0);
  121.     }
  122.  
  123.     // SuperCede End 2.0 Form Members
  124. }
  125.  
  126. // SuperCede Begin 2.0 Form Connectors
  127. // Do not remove the Begin and End markers.
  128. // The editor will rewrite the contents of this section each time the form is saved.
  129.  
  130. // Connections for this Form:
  131. //    Form1WindowClosingConnector0: from Form1.windowClosing to Form1.form1WindowClosing
  132. //    Form1WindowClosedConnector1: from Form1.windowClosed to Form1.form1WindowClosed
  133. //    Form1EventConnector3: from java.awt.TextField.actionPerformed to Form1.inputFieldActionPerformed
  134. //    Form1EventConnector4: from java.awt.Button.actionPerformed to Form1.addButtonActionPerformed
  135. //    Form1EventConnector5: from java.awt.Button.actionPerformed to Form1.clearButtonActionPerformed
  136.  
  137. final class Form1WindowClosingConnector0 extends WindowAdapter implements SuperCedeConnector
  138. {
  139.     private Form1 windowClosingTarget;
  140.  
  141.     public void setWindowClosingTarget(Form1 target)
  142.     {
  143.         windowClosingTarget = target;
  144.     }
  145.  
  146.     public void windowClosing(WindowEvent arg0)
  147.     {
  148.         windowClosingTarget.form1WindowClosing(arg0);
  149.     }
  150.  
  151.     public void setTarget(Object target)
  152.     {
  153.         setWindowClosingTarget((Form1) target);
  154.     }
  155. }
  156.  
  157. final class Form1WindowClosedConnector1 extends WindowAdapter implements SuperCedeConnector
  158. {
  159.     private Form1 windowClosedTarget;
  160.  
  161.     public void setWindowClosedTarget(Form1 target)
  162.     {
  163.         windowClosedTarget = target;
  164.     }
  165.  
  166.     public void windowClosed(WindowEvent arg0)
  167.     {
  168.         windowClosedTarget.form1WindowClosed(arg0);
  169.     }
  170.  
  171.     public void setTarget(Object target)
  172.     {
  173.         setWindowClosedTarget((Form1) target);
  174.     }
  175. }
  176.  
  177. final class Form1EventConnector3 implements SuperCedeConnector, java.awt.event.ActionListener
  178. {
  179.     private Form1 actionPerformedTarget;
  180.  
  181.     public void setActionPerformedTarget(Form1 target)
  182.     {
  183.         actionPerformedTarget = target;
  184.     }
  185.  
  186.     public void actionPerformed(ActionEvent arg0)
  187.     {
  188.         actionPerformedTarget.inputFieldActionPerformed(arg0);
  189.     }
  190.  
  191.     public void setTarget(Object target)
  192.     {
  193.         setActionPerformedTarget((Form1) target);
  194.     }
  195. }
  196.  
  197. final class Form1EventConnector4 implements SuperCedeConnector, java.awt.event.ActionListener
  198. {
  199.     private Form1 actionPerformedTarget;
  200.  
  201.     public void setActionPerformedTarget(Form1 target)
  202.     {
  203.         actionPerformedTarget = target;
  204.     }
  205.  
  206.     public void actionPerformed(ActionEvent arg0)
  207.     {
  208.         actionPerformedTarget.addButtonActionPerformed(arg0);
  209.     }
  210.  
  211.     public void setTarget(Object target)
  212.     {
  213.         setActionPerformedTarget((Form1) target);
  214.     }
  215. }
  216.  
  217. final class Form1EventConnector5 implements SuperCedeConnector, java.awt.event.ActionListener
  218. {
  219.     private Form1 actionPerformedTarget;
  220.  
  221.     public void setActionPerformedTarget(Form1 target)
  222.     {
  223.         actionPerformedTarget = target;
  224.     }
  225.  
  226.     public void actionPerformed(ActionEvent arg0)
  227.     {
  228.         actionPerformedTarget.clearButtonActionPerformed(arg0);
  229.     }
  230.  
  231.     public void setTarget(Object target)
  232.     {
  233.         setActionPerformedTarget((Form1) target);
  234.     }
  235. }
  236.  
  237. // The following line must be the last line in the file.
  238. // SuperCede End 2.0 Form Connectors
  239.